package org.study.id.leaf.core.segment.model;

import lombok.Getter;
import lombok.Setter;

import java.util.concurrent.atomic.AtomicLong;

public class Segment {
    @Setter
    @Getter
    private AtomicLong value = new AtomicLong(0);
    @Setter
    @Getter
    private volatile long max;
    @Setter
    @Getter
    private volatile int step;
    @Getter
    private SegmentBuffer buffer;

    public Segment(SegmentBuffer buffer) {
        this.buffer = buffer;
    }

    public long getIdle() {
        return this.getMax() - getValue().get();
    }
}
